<?php

?>
    <style>
        legend {
            width: auto !important;
            border-style: none !important;
        }
    </style>
    <div class="wrapper wrapper-content ibox-content">
        <fieldset class="layui-elem-field layui-field-title site-title">
            <legend><a name="use">基础信息</a></legend>
        </fieldset>
        <div class="row row-no-gutters">
            <div class="col-xs-4">昵称：<?= $model->nickname ?></div>
            <div class="col-xs-4">头像：<img class="image-show" src="<?= $model->headimgurl ?>" width="80px" height="80px">
            </div>
        </div>
        <div class="row row-no-gutters" style="margin-top: 10px">
            <div class="col-xs-4">注册时间：<?= $model->create_time ?></div>
        </div>
        <fieldset class="layui-elem-field layui-field-title site-title">
            <legend><a name="use">消费能力</a></legend>
        </fieldset>
        <div class="row row-no-gutters">
            <div class="col-xs-4">本月消费金额：<?= $month['order_amount'] ?></div>
            <div class="col-xs-4">本月订单笔数：<?= $month['number'] ?></div>
            <div class="col-xs-4">累积消费金额：<?= $total['order_amount'] ?></div>
        </div>
        <div class="row row-no-gutters" style="margin-top: 10px">
            <div class="col-xs-4">累积订单笔数：<?= $total['number'] ?></div>
        </div>
        <fieldset class="layui-elem-field layui-field-title site-title">
            <legend><a name="use">消费明细</a></legend>
        </fieldset>
        <div class="layui-tab layui-tab-card" lay-filter="test1">
            <ul class="layui-tab-title">
                <li class="layui-this" lay-id="1">收获地址</li>
                <li lay-id="2">下单管理</li>
                <li lay-id="3">购买会员卡</li>
            </ul>
            <div class="layui-tab-content" style="height: 100px;">
                <div class="layui-tab-item layui-show">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
<?php $this->beginBlock('script'); ?>
    <script>
        var type = 1;
        layui.use('element', function () {
            var element = layui.element;
            element.on('tab(test1)', function () {
                type = Number(this.getAttribute('lay-id'));
                getTableData();
            });
        });
        getTableData()

        function getTableData() {
            $('#bootstrap-table').bootstrapTable('destroy');
            var options = {
                search: false,
                showRefresh: false,
                showSearch: false,
                showColumns: false,
                showToggle: false
            }
            switch (type) {
                case 1:
                    options.modalName = '地址';
                    options.url = "<?=\yii\helpers\Url::to(['address', 'userid' => $id])?>";
                    options.columns = [
                        {field: 'consignee', title: '联系人'},
                        {field: 'mobile', title: '电话'},
                        {
                            field: 'province',
                            title: '地址',
                            formatter: function (value, row, index) {
                                return row.province + row.city + row.district + row.address;
                            }
                        }
                    ]
                    break;
                case 2:
                    options.modalName = '订单';
                    options.url = "<?=\yii\helpers\Url::to(['order', 'userid' => $id])?>";
                    options.columns = [
                        {field: 'order_sn', title: '订单编号'},
                        {
                            field: 'province',
                            title: '收货地址',
                            formatter: function (value, row, index) {
                                return row.province + row.city + row.district + row.address;
                            }
                        },
                        {field: 'total_num', title: '商品数量'},
                        {field: 'total_amount', title: '订单总额'},
                        {field: 'discount_amount', title: '优惠金额'},
                        {field: 'pay_amount', title: '实付金额'},
                        {field: 'pay_time', title: '订单支付时间'}
                    ]
                    break;
                case 3:
                    options.sortName = "create_time";
                    options.sortOrder = "desc";
                    options.modalName = '购买会员卡';
                    options.url = "<?=\yii\helpers\Url::to(['vip-log', 'userid' => $model->id])?>";
                    options.columns = [
                        {field: 'orderid', title: '订单号'},
                        {field: 'amount', title: '支付金额'},
                        {field: 'title', title: '名称'},
                        {field: 'days', title: '天数'},
                        {
                            field: 'status', title: '状态',
                            formatter: function (value, row, index) {
                                return '支付成功';
                            }
                        },
                    ]
                    break;
            }
            $.table.init(options);
        }
    </script>
<?php $this->endBlock(); ?>